<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted Access');

$keywords = $this->escape($this->state->keywords);

$research_location = $this->escape($this->state->research_location);
$investigator = $this->escape($this->state->investigator);
$organisation_involved = $this->escape($this->state->organisation_involved);
$type_of_project = $this->escape($this->state->type_of_project);

$leftcol_width = $this->escape($this->params->get('leftcol_width'));
$perpage = $this->escape($this->pagination->limit);
$limitstart = $this->escape($this->pagination->limitstart);
$listOrder	= $this->escape($this->state->get('list.ordering'));
$listDirn	= $this->escape($this->state->get('list.direction'));
?>

<style>
.current-research label , table.current-search, .current-research select{
	width:<?php echo $leftcol_width;?>px;
}
</style>

<script type="text/javascript">
//Thanh Lam: ajax control 
window.addEvent('domready', function() {	
	toggleItems(<?php echo $this->max_number_items_perpage;?>);		
	addAjaxNavigator();			
	addKeywords(options);
	
	
	$$('input.textbox').each(function(el){
		el.addEvent('keydown', function(e){
			if(e.key == "enter"){
				e.stop();				
				addKeywords(options);			
				ajaxsubmit();
			}
        });
	});	
	$$('button.search-button').each(function(el){
		el.addEvent('click', function(e){			
				e.stop();								
				addKeywords(options);			
				ajaxsubmit();	
        });
	});		
	
	$('type_of_project').addEvent( 'change', function(e){			
		e.stop();
		addKeywords(options);			
		ajaxsubmit();
	} );
	
//	loadlist($('select#lead_organisation').get(0),/*the 'select' object*/
	//		 'index.php?option=com_nrmresearch&view=organisations&layout=ajax_result',/*the url of the server-side script*/
		//	 'name'/*The name of the field in the returned list*/
	//);
});

</script>

<div class="current-research" style="float:left;width:<?php echo $leftcol_width;?>px; margin-right:10px;">

<table  class="current-search" >
  <tr>   
    <td><strong>Categories</strong></td>
  </tr>
  <tr class="current-category">
  	<td style="font-style: italic;">Current Research</td>  	
  	<!-- <td width="5%"><a href="#">x</a></td> -->
  </tr>
  
  <tr id="current-keywords-header" class="hidden">    
    <td class="leader" valign="bottom"><strong>Keywords</strong></td>
  </tr>
  <tr id="current-keywords" class="current-keywords hidden">
  	<td id="current-keywords-value" style="font-style: italic;"></td>  	
  	<td id="current-keywords-dispose"  width="5%"><a>x</a></td>
  </tr>
  
  <tr id="current-research_location-header" class="hidden">   
    <td class="leader" valign="bottom"><strong><?php echo RES_LOCATION;?></strong></td>
  </tr>
  <tr id="current-research_location" class="current-research_location hidden">
  	<td id="current-research_location-value" style="font-style: italic;"></td>  	
  	<td id="current-research_location-dispose" width="5%"><a >x</a></td>
  </tr>
  
  <tr id="current-investigator-header" class="hidden">   
    <td class="leader" valign="bottom"><strong><?php echo INVESTIGATOR_LABEL;?></strong></td>
  </tr>
  <tr id="current-investigator" class="hidden">
  	<td id="current-investigator-value" style="font-style: italic;"></td>  	
  	<td id="current-investigator-dispose" width="5%"><a >x</a></td>
  </tr>
  
    <tr id="current-organisation_involved-header" class="hidden">   
    <td class="leader" valign="bottom"><strong><?php echo ORGANISATION_INVOLVED_LABEL;?></strong></td>
  </tr>
  <tr id="current-organisation_involved" class="current-organisation_involved hidden">
  	<td id="current-organisation_involved-value" style="font-style: italic;"></td>  	
  	<td id="current-organisation_involved-dispose" width="5%"><a >x</a></td>
  </tr>
  
  <tr id="current-type_of_project-header" class="hidden">   
    <td class="leader" valign="bottom"><strong><?php echo TYPE_OF_PROJECT_LABEL;?></strong></td>
  </tr>
  <tr id="current-type_of_project" class="hidden">
  	<td id="current-type_of_project-value" style="font-style: italic;"></td>  	
  	<td id="current-type_of_project-dispose" width="5%"><a >x</a></td>
  </tr>
    
</table>

<div class="refine-search">
<label>Narrow your results:</label>
<input class="textbox" id="keywords"   autocomplete="off" value="<?php echo KEYWORD_LABEL;?>" onBlur="if(this.value=='') this.value='<?php echo KEYWORD_LABEL;?>'" onFocus="if(this.value =='<?php echo KEYWORD_LABEL;?>' ) this.value=''"><button class="search-button"></button>
</div>

<div class="category-specific">

<input class="textbox" id="research_location"  value="<?php echo RES_LOCATION;?>" onBlur="if(this.value=='') this.value='<?php echo RES_LOCATION;?>'" onFocus="if(this.value =='<?php echo RES_LOCATION;?>' ) this.value=''">
<input class="textbox" id="investigator"  value="<?php echo INVESTIGATOR_LABEL;?>" onBlur="if(this.value=='') this.value='<?php echo INVESTIGATOR_LABEL;?>'" onFocus="if(this.value =='<?php echo INVESTIGATOR_LABEL;?>' ) this.value=''">
<input class="textbox" id="organisation_involved"  value="<?php echo ORGANISATION_INVOLVED_LABEL;?>" onBlur="if(this.value=='') this.value='<?php echo ORGANISATION_INVOLVED_LABEL;?>'" onFocus="if(this.value =='<?php echo ORGANISATION_INVOLVED_LABEL;?>' ) this.value=''">

<select id="type_of_project">
	<option value="">Type of project</option>
	<option <?php if($type_of_project==MAJOR_FUNDING) echo 'selected="selected"';?>  value="<?php echo MAJOR_FUNDING?>"><?php echo MAJOR_FUNDING?></option>
	<option <?php if($type_of_project==PHD_AND_MASTERS_PROJECTS) echo 'selected="selected"';?> value="<?php echo PHD_AND_MASTERS_PROJECTS?>"><?php echo PHD_AND_MASTERS_PROJECTS?></option>
	<option <?php if($type_of_project==HONOURS_PROJECTS) echo 'selected="selected"';?> value="<?php echo HONOURS_PROJECTS;?>"><?php echo HONOURS_PROJECTS;?></option>
	
</select>
</div>
</div>

<div id="search-params-hidden">
<input type="hidden" name="layout" value="ajax_result" />	 
	<input id="ajax-keywords" type="hidden" name="keywords" value="<?php echo $keywords;?>" />
	<input id="ajax-research_location" type="hidden" name="research_location" value="<?php echo $research_location;?>" />
	<input id="ajax-investigator" type="hidden" name="investigator" value="<?php echo $investigator;?>" />
	<input id="ajax-organisation_involved" type="hidden" name="organisation_involved" value="<?php echo $organisation_involved;?>" />
	<input id="ajax-type_of_project" type="hidden" name="type_of_project" value="<?php echo $type_of_project;?>" />  
	<input id="ajax-limit" type="hidden" name="limit" value="<?php echo $perpage;?>" />
	<input id="ajax-limitstart" type="hidden" name="limitstart" value="<?php echo $limitstart;?>" />
	<input id="ajax-filter_order_Dir" type="hidden" name="filter_order_Dir" value="<?php echo $listDirn;?>" />	
	<input id="ajax-filter_order" type="hidden" name="filter_order" value="<?php echo $listOrder;?>" />	
</div>
